Transformations allow you to manipulate the visual appearance of elements by rotating, scaling, translating, or skewing them. Lets learn one by on:
Moves an element along the x and y-axis.
1. translate-x-{value}: Moves the element horizontally by {value}.
2. translate-y-{value}: Moves the element vertically by {value}.
<button class="transform translate-x-8 bg-blue-500 text-white px-4 py-2 rounded">Click Me</button>
Note: transform translate-x-8: shifting it 8 pixels to the right along the X-axis.
Increases or decreases the size of an element.
1. scale-{value}: Scales the element uniformly by {value}.
2. scale-x-{value}: Scales the element horizontally by {value}.
3. scale-y-{value}: Scales the element vertically by {value}.
<span class="transform scale-75 bg-gray-200 text-gray-700 px-2 py-1 rounded">New</span>
Explanation: scale-75 class shrinks the badge element to 75% of its original size
Rotates an element clockwise or counterclockwise.
1. rotate-{value}: Rotates the element clockwise by {value} degrees.
<img class="transform rotate-3 rounded shadow-md" src="picture.jpg" alt="Tilted Picture">
Explanation: rotate-3 class gives the image a subtle 3-degree clockwise tilt for a more dynamic look.
Skews an element along the x or y-axis.
skew-x-{value}: Skews the element along the x-axis by {value} degrees.
skew-y-{value}: Skews the element along the y-axis by {value} degrees.
<div class="transform skew-x-2 bg-white shadow-md rounded-lg px-4 py-3">
<p class="text-gray-700 font-light leading-relaxed">"This is a quote with a subtle tilt, adding a touch of personality."</p>
<span class="text-gray-500 text-sm font-italic block mt-2">- Author Name</span>
</div>